 <?php session_start(); ?>
<!DOCTYPE HTML>
<html>
    <div class="container">
<head>
        <title>Stewie's Market</title>
        <link rel="stylesheet" href="cs2102.css">

        <script type="text/javascript">
        
               function validateForm()
        {
                var subject = document.forms["message_item"]["subject"].value;
                var body = document.forms["message_item"]["body"].value;
                
                         
                if (subject == null || subject == "")
                {
                        alert("You have to give the message a subject");
                        return false;
                }
                if (body == null || body == "")
                {
                        alert("You have to write your body without leaving it blank");
                        return false;
                }
 
        }

          </script>
</head>

<body>

        <!-- Site navigation menu -->
        <?php include 'nav.php'; 

        $matric = $_GET['matric'];
        $receiver = $_GET['receiver'];
        print "<br /><h1>Send a message</h1>";
        print "To: ".$receiver." <br>";

        ?>


        <form action="messageform.php" method="get" name="message_item" onsubmit="return validateForm()">
                         
                <input type = "hidden" name="sender" value = <?php echo $_SESSION['user'] ?> >
                <input type = "hidden" name="receiver" value = <?php echo $matric ?>>
                <br>Subject<br>
                <input type="text" name="subject" size="60">
                <br>
                
                <br>Text Message:<br>
                <textarea rows="10" cols="60" placeholder="Enter message here..." name="body">
                </textarea><br><br>

                <input type="submit" value="Submit">
        </form>

        <!-- Sign and date the page, it's only polite! -->
        <address>Made by Project group 31 for CS2102, NUS 2013.</address>

</body>
</div>
</html>